Skip to content

Add missing Program and Project Methods - #64988

Open
Isabel Duan (iisaduan) wants to merge 17 commits into
microsoft:mainfrom
iisaduan:programApi
Open

Isabel Duan (iisaduan) wants to merge 17 commits into
microsoft:mainfrom
iisaduan:programApi

Conversation

@iisaduan

@iisaduan Isabel Duan (iisaduan) commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Missing Program API methods: https://github.com/microsoft/TypeScript/pull/64749/changes#diff-4776036ff539c2fa009621dc13a9f2c8fd15d50e9302e8a361614ab640659a2eR117

  • getIdentifierCount() - Total parsed identifiers across the program’s source files.
  • getInstantiationCount() - Number of type-instantiation operations performed by the API checker.
  •  getNodeCount() - Total syntax-tree nodes across the program’s source files.
  •  getOptionsDiagnostics() - Sorted, deduplicated compiler-option and configuration-related program diagnostics. Excludes source-file and config-parsing diagnostics.
  •  getProjectReferences() - Direct project references declared for the program, or  undefined  when absent.
  •  getRelationCacheSizes() - Current entry counts in the checker’s  assignable ,  identity ,  subtype , and  strictSubtype  caches.
  •  getResolvedProjectReferences()  - Resolved reference graph, including parsed configurations, config source files, and nested references. Preserves shared/circular references and missing entries.
  •  getRootFileNames() - Root file names supplied when creating the program or obtained from its configuration—not imported dependencies.
  •  getSourceFiles() - All loaded source files, including dependencies and libraries, in program order. Reuses cached source-file objects.
  •  getSymbolCount() - Binder-created symbols across source files plus symbols allocated by the API checker.
  •  getTypeChecker() - Initializes the server-side API checker if necessary and returns the project’s existing Checker object.
  •  getTypeCount() - Number of types allocated by the API checker.

Project API Methods:

  •  containsFile
  •  getFileNames
  •  getRootFiles
  •  hasRoots,
  • isRoot 
  •  hasConfigFile
  •  getSourceFile

@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 28, 2026
@iisaduan Isabel Duan (iisaduan) changed the title program init Add missing Program and Project Methods Oct 28, 2026
@iisaduan
Isabel Duan (iisaduan) marked this pull request as ready for review October 28, 2026 07:27
Copilot AI balanced review requested due to automatic review settings October 28, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The filesystem check incorrectly excludes in-program supplemental files without physical files, causing containsFile to return false even when getSourceFile succeeds.

1 open issue
What changed in this PR

Adds missing Program and Project methods to the JavaScript API, backed by native compiler and project services.

Changes:

  • Exposes program statistics, checker access, file lists, option diagnostics, and resolved project references.
  • Adds project membership, root-file, and configuration-file queries.
  • Updates protocol definitions and generated synchronous APIs, with behavioral and generator-parity tests.
File Description
tsc/​internal/​project/​projectcollection.go Checks editor- and API-open files.
tsc/​internal/​compiler/​program.go Collects filtered option diagnostics.
tsc/​internal/​checker/​types.go Defines relation-cache statistics.
tsc/​internal/​checker/​exports.go Exposes relation-cache entry counts.
tsc/​internal/​api/​session.go Implements new API request handlers.
tsc/​internal/​api/​session_program_test.go Tests membership, statistics, and checker reuse.
tsc/​internal/​api/​proto.go Defines new requests and response types.
packages/​typescript/​test/​sync/​api.test.ts Adds generated synchronous API tests.
packages/​typescript/​test/​sync/​api-generators.test.ts Checks generator parity for new methods.
packages/​typescript/​test/​async/​api.test.ts Tests new methods and edge cases.
packages/​typescript/​src/​api/​sync/​api.ts Adds generated synchronous and generator methods.
packages/​typescript/​src/​api/​proto.generated.ts Updates generated protocol declarations.
packages/​typescript/​src/​api/​async/​api.ts Implements asynchronous Program and Project methods.

Review effort: Balanced

Comment thread tsc/internal/api/session.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Concurrent cold-cache calls can return inconsistent project-reference object identities, while sequential per-file requests prevent automatic batching and add a round trip for each file.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread packages/typescript/src/api/sync/api.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the added Program and Project API methods.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the inline comments, let's remove

  • program.getSourceFiles()—not a good idea for anyone to do this pre-filtering; we'll think about an explicitly filtered and/or streaming batch API in the future
  • program.getTypeChecker()—that's not the ownership model anymore, and there's no reason to make an API request for it
  • all of the Project methods; they can all be done more directly off Program and ParsedCommandLine so I don't want to expand that API surface unnecessarily.

Comment thread tsc/internal/api/session.go Resolved
Comment thread tsc/internal/api/session.go Resolved
Comment thread tsc/internal/compiler/program.go Resolved
@iisaduan

Copy link
Copy Markdown
Member Author

removed GetResolvedProjectReferences to rethink its implementation later. Relevant comments for later:
#64988 (comment)
#64988 (comment)

@iisaduan
Isabel Duan (iisaduan) added this pull request to the merge queue Nov 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants